﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'GetIdOrdenCompraByProveedor')
	BEGIN
		DROP  Procedure  GetIdOrdenCompraByProveedor
	END

GO

CREATE Procedure GetIdOrdenCompraByProveedor

	(
		@idProveedor int
	)

AS

BEGIN
	SET NOCOUNT ON
	
	SELECT 
	OC.[IdOrdenCompra]
	FROM [OrdenCompra] AS OC
	WHERE OC.[IdProveedor] = @idProveedor AND OC.[Estado] = 0
	ORDER BY OC.[IdOrdenPedido] DESC

	SET NOCOUNT OFF
END

GO


GRANT EXEC ON GetIdOrdenCompraByProveedor TO PUBLIC

GO

